﻿using DocumentFormat.OpenXml.Drawing.Charts;
using IDEAMS.core.deviceClient;
using IDEAMS.core.opm;
using IDEAMS.model.alarm;
using IDEAMS.model.device;
using IDEAMS.model.result;
using System;
using System.Windows.Media;

namespace IDEAMS.model
{
    public class DeviceInfoViewModel : ViewModelBase
    {
        public bool isBreak;

        public ProcessResult processResult { get; set; }
        public AlarmInfoCollection alarmInfoCollection { get; set; }

        public DeviceInfoViewModel()
        {
            processResult = new ProcessResult();
            step = ProcessStep.PRE_ETALON;

            deviceParam = new DeviceParamViewModel();

            ssResp = new SpectrumSummaryResp();

            connectionStatus = ConnectionStatus.OFFLINE;

            alarmInfoCollection = new AlarmInfoCollection();

            status = DeviceStatus.NORMALI;
            maxContinuousRunTime = 0;
            continuousRunTime = 0;
            testDate = DateTime.Now;
            frequency = 0;
            isBreak = false;
        }

        public DeviceInfoViewModel(DeviceInfo deviceInfo)
        {
            this.serialNo = deviceInfo.serialNo;
            this.ip = deviceInfo.ip;
            this.port = deviceInfo.port;
            this.backgroundColor = deviceInfo.backgroundColor;

            step = deviceInfo.step;

            processResult = deviceInfo.processResult.Clone();

            deviceParam = new DeviceParamViewModel(deviceInfo.deviceParam);

            ssResp = deviceInfo.ssResp.Clone();

            alarmInfoCollection = deviceInfo.alarmInfoCollection.Clone();

            status = deviceInfo.status;
            maxContinuousRunTime = deviceInfo.maxContinuousRunTime;
            continuousRunTime = deviceInfo.continuousRunTime;
            testDate = deviceInfo.testDate;
            frequency = deviceInfo.frequency;
        }

        public DeviceInfoViewModel(DeviceInfoViewModel deviceInfo)
        {
            this.serialNo = deviceInfo.serialNo;
            this.ip = deviceInfo.ip;
            this.port = deviceInfo.port;
            this.backgroundColor = deviceInfo.backgroundColor;

            step = deviceInfo.step;

            processResult = deviceInfo.processResult.Clone();

            deviceParam = new DeviceParamViewModel(deviceInfo.deviceParam);

            ssResp = deviceInfo.ssResp.Clone();

            alarmInfoCollection = deviceInfo.alarmInfoCollection.Clone();

            status = deviceInfo.status;
            maxContinuousRunTime = deviceInfo.maxContinuousRunTime;
            continuousRunTime = deviceInfo.continuousRunTime;
            testDate = deviceInfo.testDate;
            frequency = deviceInfo.frequency;
        }

        /// <summary>
        /// 设备序列号
        /// </summary>
        private string m_serialNo;
        public string serialNo 
        {  
            get { return m_serialNo; }
            set
            {
                m_serialNo = value;
                NotifyPropertyChanged();
            }
        }
        /// <summary>
        /// 当前ip
        /// </summary>
        private string m_ip;
        public string ip
        {
            get { return m_ip; }
            set
            {
                m_ip = value;
                NotifyPropertyChanged();
            }
        }
        /// <summary>
        /// 当前端口号
        /// </summary>
        private int m_port;
        public int port
        {
            get { return m_port; }
            set
            {
                m_port = value;
                NotifyPropertyChanged();
            }
        }
        /// <summary>
        /// 背景色
        /// </summary>
        private Brush m_backgroundColor;
        public Brush backgroundColor
        {
            get { return m_backgroundColor; }
            set
            {
                m_backgroundColor = value;
                NotifyPropertyChanged();
            }
        }

        private ProcessStep m_step;
        public ProcessStep step
        {
            get { return m_step; }
            set
            {
                m_step = value;
                NotifyPropertyChanged();
            }
        }

        private DeviceParamViewModel m_deviceParam;
        public DeviceParamViewModel deviceParam
        {
            get { return m_deviceParam; }
            set
            {
                m_deviceParam = value;
                NotifyPropertyChanged();
            }
        }

        private SpectrumSummaryResp m_ssResp;
        public SpectrumSummaryResp ssResp
        {
            get { return m_ssResp; }
            set
            {
                m_ssResp = value;
                NotifyPropertyChanged();
            }
        }

        private ConnectionStatus m_connectionStatus;
        public ConnectionStatus connectionStatus
        {
            get { return m_connectionStatus; }
            set
            {
                m_connectionStatus = value;
                NotifyPropertyChanged();
            }
        }

        public DeviceInfoViewModel Clone()
        {
            return new DeviceInfoViewModel(this);
        }

        private DeviceStatus m_status;
        public DeviceStatus status
        {
            get { return m_status; }
            set
            {
                m_status = value;
                NotifyPropertyChanged();
            }
        }

        private double m_maxContinuousRunTime;
        public double maxContinuousRunTime
        {
            get { return m_maxContinuousRunTime; }
            set
            {
                m_maxContinuousRunTime = value;
                NotifyPropertyChanged();
            }
        }

        private double m_continuousRunTime;
        public double continuousRunTime
        {
            get { return m_continuousRunTime; }
            set
            {
                m_continuousRunTime = value;
                NotifyPropertyChanged();
            }
        }

        private DateTime m_testDate;
        public DateTime testDate
        {
            get { return m_testDate; }
            set
            {
                m_testDate = value;
                NotifyPropertyChanged();
            }
        }

        private int m_frequency;

        public int frequency
        {
            get { return m_frequency; }
            set
            {
                m_frequency = value;
                NotifyPropertyChanged();
            }
        }
    }
}
